package com.query;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.common.constant.PageConstant;
import lombok.Getter;

/**
 * @className: BaseQuery
 * @description: 基础查询类
 * @author: Li Chuanwei
 * @date: 2024/02/03 19:38
 * @Company: Copyright [日期] by [作者或个人]
 **/

public class BaseQuery<T> {
    private Long current;
    private Long size;

    @Getter
    private String keywords;

    public IPage<T> toPage() {
        return new Page<>(getCurrent(), getSize());
    }

    public Long getCurrent() {
        if (current == null || current <= 0) {
            return PageConstant.PAGE_NUM;
        }
        return current;
    }

    public Long getSize() {
        if (size == null || size <= 0) {
            return PageConstant.PAGE_SIZE;
        }
        return size;
    }
}
